# -*- coding =utf-8 -*-
# @Time : 2022/9/16 10:31
# @Author :1814-09胡海燕
# @File : 5-1.py
# @Software : PyCharm
import urllib.request

from urllib.request import urlretrieve

import getImage

url = 'https://www.tute.edu.cn/xysh/yxtzsd/1.htm'

response = urllib.request.urlopen(url)  # 用于打开一个远程的url连接,并且向这个连接发出请求,获取响应结果

cc = ""

cc = response.read().decode('utf-8')
print(cc)

# print(response.headers)

list1 = getImage.getImg(cc)

print("总共找到了{0}张图片".format(len(list1)))

# urlll = 'https://www.tute.edu.cn/_mediafile/tutenew/2012/08/28/2ggtofh6of.jpg'


num = int(input("请输入要下载的图片数："))

for i in range(num):
    urlretrieve(list1[i], 'img{0}.jpg'.format(i))

print("下载成功")
